home *** CD-ROM | disk | FTP | other *** search
/ Video Toaster 4.2 / Video Toaster v4.2.iso / arexx / modeler / logotron.lwm < prev    next >
Text File  |  1993-12-13  |  3KB  |  153 lines

  1. /* CMD: Logotron
  2.  *
  3.  * Generate nice beveled text.
  4.  */
  5.  
  6. call addlib "rexxsupport.library", 0, -30, 0
  7. call addlib "rexxmathlib.library", 0, -30, 0
  8. call addlib "LWModelerARexx.port", 0
  9.  
  10.  
  11. sysnam = 'Logotron'
  12. filnam = 'T:textile.state'
  13. version = 'Textile v1.01'
  14.  
  15. styles = 'Flat Block Chisel Round'
  16. corners = 'B B S S'
  17.  
  18. /* Setup state.  Read stored one, if any.
  19.  */
  20. font = 0
  21. str  = "Logo"
  22. typ  = 1
  23. deep = 0.1
  24. wide = 0.02
  25.  
  26. if (exists(filnam)) then do
  27.     if (~open(state, filnam, 'R')) then break
  28.     if (readln(state) = version) then do
  29.     parse value readln(state) with font typ deep wide .
  30.     str = readln(state)
  31.     end
  32.     call close state
  33.  
  34.     if (font > fontcount()) then font = 0
  35. end
  36.  
  37.  
  38. /* Post values for inspection and update.
  39.  */
  40. call req_begin sysnam
  41.  
  42. id_font = req_addcontrol("Font", 'f')
  43. id_str  = req_addcontrol("Text", 's', 30)
  44. id_typ  = req_addcontrol("Style", 'c', styles)
  45. id_deep = req_addcontrol("Depth", 'n', 1)
  46. id_wide = req_addcontrol("Edge Width", 'n', 1)
  47.  
  48. call req_setval id_font, font
  49. call req_setval id_str,  str
  50. call req_setval id_typ,  typ
  51. call req_setval id_deep, deep, 0.1
  52. call req_setval id_wide, wide, 0.02
  53.  
  54. if (~req_post()) then do
  55.     call req_end
  56.     exit
  57. end
  58.  
  59. font = req_getval(id_font)
  60. str  = req_getval(id_str)
  61. typ  = req_getval(id_typ)
  62. deep = req_getval(id_deep)
  63. wide = req_getval(id_wide)
  64.  
  65. call req_end
  66.  
  67.  
  68. /* Save state now, in case something fails.
  69.  */
  70. if (open(state, filnam, 'W')) then do
  71.     call writeln state, version
  72.     call writeln state, font typ deep wide
  73.     call writeln state, str
  74.     call close state
  75. end
  76.  
  77.  
  78. /* Get some scratch layers.
  79.  */
  80. origl = curlayer()
  81. empty = emptylayers()
  82. if (words(empty) < 2) then do
  83.     call notify 1,syscode,"!Need at least two empty layers","!for this operation."
  84.     exit
  85. end
  86. sl1 = word(empty, 1)
  87. sl2 = word(empty, 2)
  88.  
  89. /* Compute a good base name for surfaces.
  90.  */
  91. sbase = ''
  92. do i=1 to words(str)
  93.     sbase = sbase || word(str, i)
  94.     if length(sbase) >= 5 then leave
  95. end
  96. if length(sbase) > 15 then sbase = left(sbase, 15)
  97.  
  98. /* Create flat character polygons in sl1 and sl2.
  99.  */
  100. call setlayer sl1
  101. call maketext(str, font, word(corners, typ), wide * 2)
  102. call copy
  103. call setlayer sl2
  104. call paste
  105.  
  106. /* Sweep out sides from copy in sl2 and remove faces.
  107.  */
  108. call sel_mode('user')
  109. call sel_polygon('set')
  110. interpret 'call Bevel_' || word(styles, typ)
  111. call cut
  112. call changesurface(sbase || "_Side")
  113.  
  114. /* Get the correct faces from sl1.
  115.  */
  116. call setlayer sl1
  117. call changesurface(sbase || "_Face")
  118. call flip
  119. call cut
  120. call setlayer sl2
  121. call paste
  122.  
  123. /* Symmeterize and clean up new object.
  124.  */
  125. call mirror(Z, -deep/2)
  126. call mergepoints
  127. call cut
  128. call setlayer origl
  129. call paste
  130.  
  131. exit
  132.  
  133.  
  134. Bevel_Block:
  135.     call bevel(0, deep / 2)
  136.     return
  137.  
  138.  
  139. Bevel_Chisel:
  140.     call shapebevel(-wide wide (-wide) deep/2)
  141.     return
  142.  
  143.  
  144. Bevel_Round:
  145.     n = 5
  146.     pat = ''
  147.     do i=1 to n
  148.         a = 3.14159/2 * i / n
  149.         pat = pat (-sin(a)*wide) (1-cos(a))*wide
  150.       end i
  151.     call shapebevel(pat (-wide) deep/2)
  152.     return
  153.